# https://cr.console.aliyun.com/repository/cn-shanghai/homesmart/localserver/images

docker build -t localserver:debug .

if [ -f "/root/.docker/conf.json" ]; then
  echo "login alrealy"
else
  docker login --username=448267696@qq.com crpi-9qpzy3u9htsic0vd.cn-shanghai.personal.cr.aliyuncs.com
fi

repository="localserver"
tag="debug"

# 获取 IMAGE ID
image_id=$(docker images --format "{{.ID}}" --filter "reference=$repository:$tag")

docker tag $image_id crpi-9qpzy3u9htsic0vd.cn-shanghai.personal.cr.aliyuncs.com/homesmart/localserver:debug
docker push crpi-9qpzy3u9htsic0vd.cn-shanghai.personal.cr.aliyuncs.com/homesmart/localserver:debug


#docker images prune

cd /opt/my-docker-data/ && docker stop localserver && docker rm localserver && docker rmi $(docker images | grep localserver | awk '{print $3}') && docker-compose up -d